import request from '@/utils/request'

/**
 * 注册接口
 * @param {*} param0 
 *  函数参数是一个对象，直接在函数参数中进行对象结构
 */
export const userRegisterService = ({ username, password, repassword }) =>{
  return request.post('/api/reg', { username, password, repassword })
}

/**
 * 登录接口
 * @param {*} param0 
 * @returns 
 */
export const userLoginService = ( {username, password} ) =>{
  return request.post('/api/login', { username, password })
}

/**
 * 获取用户基本信息
 */
export const userGetInfoService = () => {
  return request.get('/my/userinfo')
}

/**
 * 更新用户基本信息
 * @param {*} param0 
 * @returns 
 */
export const userUpdateInfoService = ({ id, nickname, email }) =>{
  return request.put('/my/userinfo', { id, nickname, email })
}

/**
 * 更新用户头像
 * @param {*} param0 
 * @returns 
 */
export const userUploadAvatarService = (avatar) =>{
  return request.patch('/my/update/avatar', { avatar })
}

/**
 * 更新用户密码
 * @param {*} param0 
 * @returns 
 */
export const userUpdatePasswordService = ({ old_pwd, new_pwd, re_pwd }) =>{
  return request.patch('/my/updatepwd', { old_pwd, new_pwd, re_pwd })
}